package com.cmc.cloud.cmclink.doc.enums.filter;

import com.cmc.cloud.cmclink.common.filter.enums.FieldType;
import lombok.Getter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 周贤
 * @date 2025/9/24
 */
public enum SiFilterConditionFieldEnum {
    /**
     * 服务路径id
     */
    ROUTE_SERVICE_ID("route_id", "routeId", FieldType.LONG.name(), "路径Id", "SI"),
    /**
     * 订舱人
     */
    BKP_CODE("bkp_code", "bkpCode", FieldType.STRING.name(), "订舱人", "SI"),
    /**
     * 订舱号
     */
    BOOKING_NO("booking_no", "bookingNo", FieldType.STRING.name(), "订舱号", "SI"),
    /**
     * 箱主
     */
    CNTR_OWNER("cntr_owner", "cntrOwner", FieldType.STRING.name(), "箱主", "SI"),
    /**
     * 协议号
     */
    AGREEMENT_NO("agreement_no", "agreementNo", FieldType.STRING.name(), "协议号", "SI"),
    /**
     * 舱位代码
     */
    SPACE_OWNER("space_owner", "spaceOwner", FieldType.STRING.name(), "舱位代码", "SI"),

    /**
     * por
     */
    POR_CODE("por_code", "porCode", FieldType.STRING.name(), "接货地", "SI"),

    /**
     * del
     */
    DEL_CODE("del_code", "delCode", FieldType.STRING.name(), "目的地", "SI"),

    /**
     * 订舱船名
     */
    BKG_VESSEL_CODE("bkg_vessel_code", "bkgVesselCode", FieldType.STRING.name(), "接货地", "SI"),

    /**
     * 订舱航次
     */
    BKG_VOYAGE("bkg_voyage", "bkgVoyage", FieldType.STRING.name(), "目的地", "SI"),

    /**
     * 货类"
     */
    CARGO_TYPE("cargo_type", "cargoType", FieldType.STRING.name(), "货类", "Cargo"),
    /**
     * HSCODE
     */
    HS_CODE("hs_code", "hsCode", FieldType.STRING.name(), "HSCODE", "Cargo"),
    /**
     * 包装编码
     */
    PACKAGE_CODE("package_code", "packageCode", FieldType.STRING.name(), "包装代码", "Cargo"),
    /**
     * 货描
     */
    COMMODITY_EN("commodity_en", "commodityEn", FieldType.STRING.name(), "货描", "Cargo"),


    /**
     * pol_code
     */
    POL_CODE("pol_code", "polCode", FieldType.STRING.name(), "装货港", "SI"),

    /**
     * pod_Code
     */
    POD_CODE("pod_code", "podCode", FieldType.STRING.name(), "卸货港", "SI"),

    /**
     * 运输方式
     */
    TRANSMODE("transmode", "transmode", FieldType.STRING.name(), "运输方式", "Vslvoy"),

    /**
     * 操船方匹配的是订舱船名航次的操船方
     */
    VESSEL_OPERATOR("vessel_operator", "vesselOperator", FieldType.STRING.name(), "操船方", "Vslvoy"),

    /**
     * 航线代码（出口）匹配的是订舱船名航次的出口航代码
     */
    LANE_CODE_EX("lane_code_ex", "laneCodeEx", FieldType.STRING.name(), "出口航代码", "Vslvoy"),


    /**
     * 箱型
     */
    CNTR_TYPE("cntr_type", "cntrType", FieldType.STRING.name(), "箱型", "Forecast"),

    /**
     * 货物毛重
     */
    GROSS_WEIGHT("gross_weight", "grossWeight", FieldType.STRING.name(), "货物毛重", "Forecast"),
    /**
     * 箱尺寸
     */
    CNTR_SIZE("cntr_size", "cntrSize", FieldType.STRING.name(), "箱尺寸", "Forecast");



    /**
     * 字段数据库名称
     */
    @Getter
    private final String columnName;

    /**
     * 字段对象名称
     */
    @Getter
    private final String fieldName;

    /**
     * 字段值类型
     */
    @Getter
    private final String fieldType;

    /**
     * 字段描述
     */
    @Getter
    private final String fieldDesc;

    /**
     * 字段描述
     */
    @Getter
    private final String objectName;

    SiFilterConditionFieldEnum(String columnName, String fieldName, String fieldType, String fieldDesc,
                             String objectName) {
        this.columnName = columnName;
        this.fieldName = fieldName;
        this.fieldType = fieldType;
        this.fieldDesc = fieldDesc;
        this.objectName = objectName;
    }

    public static Map<String, List<String>> getAllField() {
        Map<String, List<String>> result = new HashMap<>(16);
        for (SiFilterConditionFieldEnum temp : SiFilterConditionFieldEnum.values()) {
            String objectName = temp.getObjectName();
            String fieldName = temp.getFieldName();
            if (result.get(objectName) == null) {
                result.put(objectName, new ArrayList<>(16));
            }
            List<String> list = result.get(objectName);
            list.add(fieldName);
        }
        return result;
    }
}
